package com.zxm.ex.common.exception;

import com.zxm.ex.common.vo.BaseResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Slf4j
@ControllerAdvice
public class BackendExceptionHandler {


    @ExceptionHandler(BackendException.class)
    @ResponseBody
    public BaseResultVo backendException(HttpServletRequest request, BackendException e){
        log.error("BackendException code: {},message: {}",e.getCode(),e.getMessage());
        return BaseResultVo.exception(e);
    }
}
